package org.sample;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class HomeActivity extends Activity {
	private static final int PAGE1 = 1;
	
	Button btn1;
	Context me;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	me = this;
    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
        btn1 = (Button)findViewById(R.id.btn1);
        btn1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //Intent  intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel: 1122-555"));
                //startActivity(intent);
            	Intent intent = new Intent(me, Page1Activity.class);
            	intent.putExtra("v1", 100);
            	startActivityForResult(intent, PAGE1);
            }
        });
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	// TODO Auto-generated method stub
    	super.onActivityResult(requestCode, resultCode, data);
    	switch(requestCode){
    	case PAGE1:
    		if(resultCode == Activity.RESULT_OK){
    			btn1.setText("OK");
    		}else{
    			btn1.setText("Cancel");
    		}
    	}
    }
}